package com.fzrskj.cloud.free.core.enums;

/**
 * OsTypeEnum.
 *
 * @author zj.
 *         Created on 2018/10/18 0018.
 */
public enum  OsTypeEnum {
    /**
     * windows.
     */
    WINDOWS("windows", "Administrator", 3389, 1),
    /**
     * linux.
     */
    LINUX("linux", "root", 22, 2),
    Linux6_5("Linux6.5", "root", 22, 2),
    win2003("win2003.5", "Administrator", 3389, 2),
    win2012("win2012", "Administrator", 3389, 2),
    win2008R2("win2008R2", "Administrator", 3389, 2);

    /**
     * os name.
     */
    private String name;

    /**
     * os default manager account;
     */
    private String user;

    /**
     * rdp port.
     */
    private Integer rdpPort;

    /**
     * type code.
     */
    private Integer code;

    /**
     * constructor.
     * @param name os name.
     */
    OsTypeEnum(String name, String user, Integer rdpPort, Integer code) {
        this.name = name;
        this.user = user;
        this.rdpPort = rdpPort;
        this.code = code;
    }

    /**
     * get os name.
     * @return os name.
     */
    public String getName() {
        return this.name;
    }

    /**
     * get os user.
     * @return os user.
     */
    public String getUser() {
        return this.user;
    }

    /**
     * 获取rdp port.
     * @return rdp port.
     */
    public Integer getRdpPort() {
        return this.rdpPort;
    }

    /**
     * get type code.
     * @return type code.
     */
    public Integer getCode() {
        return this.code;
    }

    /**
     * 通过系统类型获取默认系统用户.
     * @param name name.
     * @return user.
     */
    public static String getUserByName(String name) {
        for (OsTypeEnum typeEnum : OsTypeEnum.values()) {
            if (typeEnum.name.equals(name)) {
                return typeEnum.getUser();
            }
        }
        return null;
    }

    /**
     * 获取系统类型.
     * @param name name.
     * @return user.
     */
    public static OsTypeEnum getInstance(String name) {
        for (OsTypeEnum typeEnum : OsTypeEnum.values()) {
            if (typeEnum.name.equals(name)) {
                return typeEnum;
            }
        }
        return null;
    }
}
